<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/7/21
 * Time: 9:26
 */

namespace app\admin\controller;

use cmf\controller\AdminBaseController;
use app\admin\model\StockModel;
use think\Session;

class OutStockController extends AdminBaseController
{

    //查出库存商品列表

    public function stockList()
    {
        $param = $this->request->param();
        if ($param) {
            $Outgoods_id = $param['Outgoods_id'];
            Session::set('outgoodsid', $Outgoods_id);
            $stockModel = new StockModel();
            $data = $stockModel->outStockList($Outgoods_id);
            $this->assign('data', $data);
        } else {
            $stockModel = new StockModel();
            $data = $stockModel->outStockList("0ss");
            $this->assign('data', $data);
        }
        return $this->fetch();
    }

//退库
    public function outStock()
    {
        $param = $this->request->param();
        $stockModel = new StockModel();
        $goods_id = Session::get('outgoodsid');
        $res = $stockModel->outStock($param ,$goods_id);
        if ($res == true) {
            $this->success('退库成功',url("stockList",['Outgoods_id'=> $goods_id]));
        } else {
            $this->error('退库失败');
        }
    }

    //退库列表
    public function outStockList ()
    {
        $stockModel = new StockModel();
        $data = $stockModel->outStockList2();
        $this->assign('data',$data);
        return $this->fetch();
    }

}